<table id="LAY-salecards-manage" lay-filter="LAY-salecards-manage"></table>
<script type="text/html" id="memberTpl">
  <img style="display:inline-block;width:30px;height:30px" src= {{ d.avatar }} >
  {{ d.nickname }}
</script>
<script type="text/html" id="cardstatusTpl">
  {{# if(d.status == 0){ }}
  <span class="layui-badge layui-bg-black">未使用</span>
  <span class="layui-badge layui-bg-blue" onclick="layui.hexiao({{d.id}})">点击核销</span>
  {{# }else{ }}
  <span class="layui-badge layui-bg-green">已使用</span>
  {{# } }}
</script> 
<script type="text/html" id="createtimeTpl"> 
  {{# var date = new Date(d.createtime * 1000);
    var dt = date.getFullYear() + '-';
    dt += (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    dt += (Array(2).join(0) + date.getDate()).slice(-2) + ' ';
    dt += (Array(2).join(0) + date.getHours()).slice(-2) + ':';
    dt += (Array(2).join(0) + date.getMinutes()).slice(-2) + ':';
    dt += (Array(2).join(0) + date.getSeconds()).slice(-2); }}
  {{ dt }}
</script>
<script>
layui.use('salecards', layui.factory('salecards')).use(['admin', 'salecards', 'table', 'upload'], function(){
  var $ = layui.$
  ,admin = layui.admin
  ,view = layui.view
  ,table = layui.table
  ,form = layui.form
  ,upload = layui.upload;

  layui.hexiao = function(id){
    layer.confirm('确定核销吗？', function() {
        $.post(
            layui.setter.baseUrl+'sale/hexiao',
            {id: id},
            function(ret){
                var {code,msg,data} = ret;
                layer.alert(msg);
                if(code==0){
                    table.reload('LAY-salecards-manage');
                }
            }
        );
      });
  }
});
</script>